<template>
	<view class="content">
		<view class="swiper-block">
				<image src="https://job-1306862033.cos.ap-chengdu.myqcloud.com/miniprogram-static/home/jq-erq/banner.png" class="img"></image>
		</view>
		<view class="menu-item">
			<view class="tab-item" :class="tabActive==0?'active':''" @click="bindActive(0)">培训报名</view>
			<!-- <view class="tab-item" :class="tabActive==1?'active':''" @click="bindActive(1)">视频课程</view> -->
			<view class="tab-item" :class="tabActive==2?'active':''" @click="bindActive(2)">培训计划</view>
		</view>
		<view class="block" v-if="tabActive==0">
			<view class="menu-block block" @click="navigate('/page_other/train/index?type=1')">
				<view class="left">
					<view class="icon">
						<image src="https://job-1306862033.cos.ap-chengdu.myqcloud.com/miniprogram-static/home/jq-erq/cy.png" style="width: 100%;height: 100%;margin-right: 10rpx;"></image>
					</view>
					<view class="title" style="margin: 0">
						创业培训
					</view>
				</view>
				<view class="right">
					<image src="https://job-1306862033.cos.ap-chengdu.myqcloud.com/miniprogram-static/home/jq-erq/right.png" style="width: 28px;height: 28px;"></image>
				</view>
			</view>
			<view class="menu-block block" @click="navigate('/page_other/train/index?type=2')">
				<view class="left">
					<view class="icon">
						<image src="https://job-1306862033.cos.ap-chengdu.myqcloud.com/miniprogram-static/home/jq-erq/jn.png" style="width: 100%;height: 100%;margin-right: 10rpx;"></image>
					</view>
					<view class="title" style="margin: 0;">
						技能培训
					</view>
				</view>
				<view class="right">
					<image src="https://job-1306862033.cos.ap-chengdu.myqcloud.com/miniprogram-static/home/jq-erq/right.png" style="width: 28px;height: 28px;"></image>
				</view>
			</view>
		</view>
		<view class="block news-block" v-if="tabActive==2">
			<block v-if="newsList.length>0">
				<view class="news-item" v-for="(item) in newsList" :key="item.id"
					@click="navigate('/page_other/train/skill/index?id='+item.id)">
					<view class="news">
						<image :src="item.coverImage" mode="aspectFill" class="news-icon"></image>
						<view class="news-content">
							<view class="news-title">{{item.title}}</view>
							<!-- <view class="desc">{{item.typeText}}</view> -->
							<view class="time" style="margin-top: 20rpx;">发布时间：{{item.createTime}}</view>
						</view>
					</view>
				</view>
			</block>
			<view v-else-if="newsList.length>0&&!listConf.more" style="text-align: center;">没有更多了哦</view>
			<view v-else class="empty">暂无数据</view>
		</view>
	</view>
</template>

<script>
	import {
		getAreasList,
		getUserTrainList,
	} from '@/api/train.js';
	import {
		getNewsList
	} from '@/api/policy.js';
	import {
		addModuleCount
	} from '@/api/policy.js';
	export default {
		data() {
			return {
				// type:1,
				page:1,
				limit:10,
				tabActive: 0,
				city: -1,
				type: [{
					id: 0,
					data: "全部"
				},],
				newsList:[],
				list:[{
					id:1,
					name:'创业培训'
				},{
					id:2,
					name:'技能培训'
				}],
			}
		},
		watch: {
		},
		methods: {
			getAddModuleCount() {
				addModuleCount({
					type: 6,
				}).then(data => {
					uni.hideLoading()
					this.form = data
				}).catch(() => {
					uni.hideLoading()
				})
			},
			getList1(type) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getNewsList({
					page: this.page,
					limit: this.limit,
					type: 2226,
					userType:'',
				}).then(data => {
					uni.hideLoading()
					this.newsList = data.list
				}).catch(() => {
					uni.hideLoading()
				})
			},
			navigate1(index) {
				const item = this.list[index];
				uni.navigateTo({
					url: `/page_other/train/index?id=${item.id}&latitude=${this.latitude}&longitude=${this.longitude}`
				})
			},
			getAreasList(typeId) {
				getAreasList().then((data) => {
					for (let i = 0; i < data.length; i++) {
						const current = data[i];
						this.type.push({
							id: current.id,
							data: current.data
						})
					}
			
				}).catch((data) => {
					console.log(res)
				})
			},
			bindType(e) {
				this.city = e.detail.value
			},
			bindActive(index) {
				this.tabActive = index
				if (this.tabActive == 0) {
				}
				if (this.tabActive == 2) {
				}
			},
			navigate(url) {
				uni.navigateTo({
					url
				})
			},

		},
		onLoad() {
			this.getAreasList()
			this.getList1()
			this.getAddModuleCount()
		},
		onReachBottom() {
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fafafa;
	}
	.middle{
		display: flex;
	}
	.label-item1 {
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 10rpx 10rpx;
		font-size: 28rpx;
		// color: #FE7526;
		// background: #FDECE5;
		margin: auto 10rpx;
		text-align: center;
		width: 210rpx;
		height: 50rpx;
		.form-ctrl {
			width: 83rpx;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
			margin: 0 auto;
			margin: 0 10rpx 0 28rpx;
			font-size: 28rpx;

		}
		image{
			width: 20rpx;
			height: 20rpx;
		}
	
	}
	.intention{
		width: 90%;
		height: 70rpx;
		font-size: 25rpx;
		// margin: 20rpx auto;
		background-color: #FC704C;
		color: #fff;
		border-radius: 40rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.menu-block {
		margin-top: 30rpx;
		background: #fff;
		border-radius: 12px;
		padding: 30rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		.title{
			font-weight: 900;
			font-size: 32rpx;
		}
		.left{
			display: flex;
			align-items: center;
			.icon{
				width: 100rpx;
				height: 100rpx;
				margin-right: 20rpx;
			}
		}
	}
		.swiper-block {
				width: 100%;
				height: 280rpx;
				box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.2);
				border-radius: 20rpx;
				.img{
					width: 100%;
					height: 100%;
				}
			}
			.block.news-block {
				.title {
					margin: 20rpx 0 30rpx 0;
				}
			
				.news {
					display: flex;
					background-color: #fff;
					padding: 25rpx;
					box-shadow: 0px 0px 4px #ccc;
					border-radius: 10rpx;
					margin-bottom: 30rpx;
					height: 230rpx;
			
					.news-icon {
						width: 180rpx;
						height: 180rpx;
						border-radius: 16rpx;
						margin-right: 20rpx;
					}
			
					.news-content {
						width: calc(100% - 200rpx);
						display: flex;
						flex-direction: column;
						justify-content: space-around;
			
						.news-title {
							font-weight: bold;
							margin-bottom: 10rpx;
							overflow: hidden;
							text-overflow: ellipsis;
							display: -webkit-box;
							-webkit-line-clamp: 1;
							-webkit-box-orient: vertical;
							word-break: break-all;
						}
			
						.desc {
							color: #999;
							font-size: 28rpx;
							margin-bottom: 10rpx;
							overflow: hidden;
							text-overflow: ellipsis;
							display: -webkit-box;
							-webkit-line-clamp: 2;
							-webkit-box-orient: vertical;
							word-break: break-all;
							height: 80rpx;
						}
			
						.time {
							color: #999;
							font-size: 28rpx;
						}
					}
				}
			}
		
	.content {
		width: 100%;
		padding: 30rpx;

		.menu-item {
			display: flex;
			align-items: center;
			margin: 40rpx 0 30rpx 0;
			padding: 0 30rpx;

			.tab-item {
				font-size: 36rpx;
				margin-right: 30rpx;
				font-weight: bold;
			}

			.tab-item.active {
				font-size: 36rpx;
				font-weight: bold;
				margin-right: 30rpx;
				color: red;
			}
		}

		.block {
			width: 100%;
			.title {
				margin: 40rpx 0 30rpx 0;

				.t-left {
					display: flex;
					align-items: center;

					.pre-icon {
						width: 15rpx;
						height: 37rpx;
						background-color: #ff7626;
						border-radius: 16rpx;
						margin-right: 10rpx;
					}

					.name {
						font-weight: bold;
					}
				}

				.more {
					font-size: 30rpx;
					color: #999;
				}
			}

		}

		
	}
</style>